PS C:\Users\cairi> $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
PS C:\Users\cairi> Write-Host "`n==== $timestamp - Network Diagnostic ===="

==== 2025-05-04 21:58:51 - Network Diagnostic ====
PS C:\Users\cairi>
PS C:\Users\cairi> $ipconfig = ipconfig
PS C:\Users\cairi> if ($ipconfig -match "IPv4 Address") {
>>     Write-Host "Ip address assigned"
>> } else {
>>     Write-Host "no ip found!"
>> }
Ip address assigned
PS C:\Users\cairi>
PS C:\Users\cairi> if (Test-Connection -ComputerName "8.8.8.8" -Count 2 -Quiet) {
>>     Write-Host "pinged to 8.8.8.8 succesfully, you have wifi!"
>> } else {
>>     Write-Host "ping failed, try again"
>> }
pinged to 8.8.8.8 succesfully, you have wifi!
PS C:\Users\cairi>
PS C:\Users\cairi> $domains = @("www.google.com", "www.microsoft.com")
PS C:\Users\cairi> $dnsSuccess = $false
PS C:\Users\cairi>
PS C:\Users\cairi> foreach ($domain in $domains) {
>>     try {
>>         $dnsResult = Resolve-DnsName $domain -ErrorAction Stop
>>         $ips = ($dnsResult | Where-Object { $_.Type -eq "A" }).IPAddress
>>         if ($ips) {
>>             Write-Host "dns resolution succesful for $domain"
>>             Write-Host "resolved ip(s): $($ips -join ', ')"
>>             $dnsSuccess = $true
>>             break
>>         }
>>     } catch {
>>         Write-Host "dns resolution failed for $domain"
>>     }
>> }
dns resolution succesful for www.google.com
resolved ip(s): 216.58.212.228
PS C:\Users\cairi>
PS C:\Users\cairi> if (-not $dnsSuccess) {
>>     Write-Host "nodns resolution succeeded"
>> }
PS C:\Users\cairi>
PS C:\Users\cairi> Write-Host "network diagnostic done"
network diagnostic done
PS C:\Users\cairi>
fwd-i-search: _